﻿using System.Windows.Media.Imaging;
using Might.Infrastructure.Annotations.Graphics;
using Might.Infrastructure.ModelicaDOM;

namespace Might.Modelica.Annotations.Graphics {
    ///<summary>
    ///</summary>
    [Mapping("Bitmap")]
    public class GraphicsBitmap : GraphicsItemEx, IGraphicsBitmap {
        /// <summary>
        /// </summary>
        public GraphicsBitmap() {
            fileName = string.Empty;
            imageSource = string.Empty;
        }
        
        #region IGraphicsBitmap Members

        public BitmapImage Image {
            get { return image; }
            set {
                if (image != value) {
                    image = value;
                    OnChanged(this, "Image");
                }
            }
        }
        private BitmapImage image;

        #endregion

        #region Specific Modelica members

        // TODO not supported yet
        ///<summary>
        ///</summary>
        [Mapping("fileName")]
        public string fileName { get; set; }

        // TODO not supported yet
        ///<summary>
        ///</summary>
        [Mapping("imageSource")]
        public string imageSource { get; set; }

        public override bool IsDefault {
            get {
                return base.IsDefault &&
                       fileName == string.Empty &&
                       imageSource == string.Empty;
            }
        }

        #endregion
    }
}